from Dao import PDBC
from ScoreAnalysis import smartScoreDescribe, scoreCorrelation, scoreClustering, scoreStability


def student_evaluation(student_id):
    """
    :param student_id:
    :return: 这个学生各个学科的等级评估
    """

    return True


def join_data(file_name):
    """
    :param file_name:
    :return:将指定格式数据插入数据库
    """
    system = PDBC.ScoreAnalysisSystem()
    system.join_data(file_name)
    return True


def single_class_course_exam(class_id, exam_id):
    """
    :param class_id:
    :param exam_id:
    :return: 描述性统计和聚类分析结果
    """
    # 连接数据库
    system = PDBC.ScoreAnalysisSystem()
    # 获取按班级和考试的数据
    df_result = system.get_class_scores_by_exam(exam_id, class_id)
    # 智能描述性统计
    smartScoreDescribe.smart_score_describe(df_result)
    # 聚类分析
    scoreClustering.score_clustering(df_result)

    return True


def single_class_exam_mutiple_course(class_id, exam_id):
    """
    :param class_id:
    :param exam_id:
    :return: 给出学生合理聚类结果，给出本次考试的关联性和最重要学科
    """
    # 连接数据库
    system = PDBC.ScoreAnalysisSystem()
    # 获取按班级和考试的数据
    df_result = system.get_class_scores_by_exam(exam_id, class_id)
    # 智能描述性统计
    smartScoreDescribe.smart_score_describe(df_result)
    # 聚类分析
    scoreClustering.score_clustering(df_result)
    # 相关性分析
    scoreCorrelation.score_correlation(df_result)
    return True


def single_class_multiple_exam(class_id, exam_course):
    """
    :param exam_course:
    :param class_id:
    :return: 分析单个科目的风格，分析班级内部排名稳定性
    """
    # 连接数据库
    system = PDBC.ScoreAnalysisSystem()
    # 获取按班级和考试的数据
    df_result = system.get_student_scores_by_exam_course(class_id, exam_course)
    # 分析班级单科目稳定情况
    scoreStability.score_stability(df_result)

    return True


def single_class_multiple_course_exam(class_id):
    """
    :param class_id:
    :return:可视化相关性分析、给出最重要学科；给出各科目班内差异程度的量化指标
    """
    system = PDBC.ScoreAnalysisSystem()
    df_result = system.get_all_scores_by_class(class_id)
    # 相关性分析
    scoreCorrelation.score_correlation(df_result)
    return True


def main():
    # 后端调试
    # 班级单科目单次考试 成功
    # single_class_course_exam('11101101', ['202111100001'])
    # 班级多科目单次考试 成功
    # single_class_exam_mutiple_course('11101101', ['202111100001', '202111200001', '202111300001', '202111400001'])
    # 班级单科风格 成功
    # single_class_multiple_exam('11101101', '数学')
    # 班级整体风格 成功
    # single_class_multiple_course_exam('11101101')

    return True


if __name__ == "__main__":
    main()
